package com.ja.openchat.ui.chat.group.adapter;

import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ja.openchat.R;
import com.ja.openchat.views.UserAvatarView;
import com.zy.openchat.core.manager.TelegramManager;
import com.zy.openchat.core.model.group.GroupMemberInfo;
import com.zy.openchat.core.model.user.UserInfo;

import org.jetbrains.annotations.NotNull;

public class GroupSettingOfMembersAdapter extends BaseQuickAdapter<GroupMemberInfo, BaseViewHolder> {

    public GroupSettingOfMembersAdapter() {
        super(R.layout.item_group_setting_of_member);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder helper, GroupMemberInfo member) {
        UserAvatarView avatarView = helper.getView(R.id.user_image);
        avatarView.setTextSize(23);
        helper.setText(R.id.user_name, TextUtils.isEmpty(member.nickname)?UserInfo.userDisplayName(member.user_id):member.nickname);
        UserInfo user = TelegramManager.getTelegramManager().getTgData().contactInfo(member.user_id);
        if (user != null) {
            avatarView.showUser(user);
        } else {
            avatarView.showName(UserInfo.userDisplayName(member.user_id));
        }
        helper.setGone(R.id.manager_status,!member.isManagerRole());
        helper.setText(R.id.user_status,UserInfo.getUserInfo(member.user_id).getUserStatusLable());
    }
}
